import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    meta: { title: '数据监测', icon: 'shuju' },
    children: [{
      path: 'index',
      name: 'Index',
      component: () => import('@/views/Index/index'),
      meta: { title: '数据监测', icon: 'shuju' }
    },
    // {
    //   path: 'patient-add',
    //   name: 'PatientAdd',
    //   component: () => import('@/views/Index/PatientAdd'),
    //   meta: { title: '新增用户', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'patient-physical/:id',
    //   name: 'PatientPhysical',
    //   component: () => import('@/views/Index/PatientPhysical'),
    //   meta: { title: '体适能测试', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'patient-Q1/:id',
    //   name: 'PatientQ1',
    //   component: () => import('@/views/Index/PatientQ1'),
    //   meta: { title: '常规健康问题', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'patient-Q2/:id',
    //   name: 'PatientQ2',
    //   component: () => import('@/views/Index/PatientQ2'),
    //   meta: { title: '体适能测试结果', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'patient-Q3/:id',
    //   name: 'PatientQ3',
    //   component: () => import('@/views/Index/PatientQ3'),
    //   meta: { title: '其他指标', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'patient-Q4/:id',
    //   name: 'PatientQ4',
    //   component: () => import('@/views/Index/PatientQ4'),
    //   meta: { title: '疾病补充问题', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'index-prescription/:id',
    //   name: 'Prescription',
    //   component: () => import('@/views/Index/Prescription'),
    //   meta: { title: '处方预览', icon: 'el-icon-s-home' },
    //   hidden: true
    // },
    // {
    //   path: 'comments/comments-add/:id',
    //   name: 'CommentsAdd',
    //   component: () => import('@/views/Comments/AddComments.vue'),
    //   meta: { title: '添加评语', icon: '' },
    //   hidden: true
    // },
    // {
    //   path: 'prescription/prescription-change/:id',
    //   name: 'PrescriptionChange',
    //   component: () => import('@/views/Prescription/Change.vue'),
    //   meta: { title: '修改处方', icon: '' },
    //   hidden: true
    // }
    // {
    //   path: 'dashboard',
    //   name: 'Dashboard',
    //   component: () => import('@/views/dashboard/index'),
    //   meta: { title: '首页', icon: 'el-icon-s-home' }
    // },
    ]
  },
  {
    path: '/history',
    component: Layout,
    redirect: '/history/history-list',
    name: 'History',
    meta: { title: '历史数据', icon: 'lishi' },
    children: [
      {
        path: 'history-list',
        name: 'HistoryList',
        component: () => import('@/views/History/HistoryList.vue'),
        meta: { title: '历史数据', icon: 'lishi' }
      },
      {
        path: 'history-detail/:id',
        name: 'HistoryDetail',
        component: () => import('@/views/History/HistoryDetail.vue'),
        meta: { title: '历史数据详情', icon: 'Group 5 Copy 2' },
        hidden: true
      }
    ]
  },
  {
    path: '/shebei',
    component: Layout,
    redirect: '/shebei/shebei-list',
    name: 'Shebei',
    meta: { title: '设备管理', icon: 'shebei' },
    children: [
      {
        path: 'shebei-list',
        name: 'ShebeiList',
        component: () => import('@/views/Shebei/ShebeiList.vue'),
        meta: { title: '设备管理', icon: 'shebei' }
      },
    ]
  },
  {
    path: '/work',
    component: Layout,
    redirect: '/work/work-add',
    name: 'Work',
    meta: { title: '家庭作业', icon: 'jiating' },
    children: [
      {
        path: 'work-add',
        name: 'WorkAdd',
        component: () => import('@/views/Work/WorkAdd.vue'),
        meta: { title: '家庭作业', icon: '' }
      },
      {
        path: 'work-select',
        name: 'WorkSelect',
        component: () => import('@/views/Work/WorkSelect.vue'),
        meta: { title: '选择内容', icon: 'jiating' },
        hidden: true
      },
      {
        path: 'work-detail/:id',
        name: 'WorkDetail',
        component: () => import('@/views/Work/WorkDetail.vue'),
        meta: { title: '作业详情', icon: 'jiating' },
        hidden: true
      },
      {
        path: 'work-history-list',
        name: 'WorkHistory',
        component: () => import('@/views/Work/WorkHistory.vue'),
        meta: { title: '作业历史列表', icon: '' },

      },
      {
        path: 'work-history-detail/:id',
        name: 'WorHistoryDetail',
        component: () => import('@/views/Work/WorkHistoryDetail.vue'),
        meta: { title: '作业详情', icon: 'Group 5 Copy 2' },
        hidden: true
      },
    ]
  },
  // {
  //   path: '/class',
  //   component: Layout,
  //   redirect: '/class/class-list',
  //   name: 'ClassList',
  //   meta: { title: '班级管理列表', icon: 'banji' },
  //   children: [
  //     {
  //       path: 'class-list',
  //       name: 'ClassList',
  //       component: () => import('@/views/Class/ClassList.vue'),
  //       meta: { title: '班级管理列表', icon: 'banji' }
  //     },
  //     {
  //       path: 'class-detail-list/:id',
  //       name: 'ClassDetailList',
  //       component: () => import('@/views/Class/ClassDetailList.vue'),
  //       meta: { title: '班级详情', icon: 'Group 5 Copy 2' },
  //       hidden: true

  //     },
  //   ]
  // },
  // {
  //   path: '/prescription',
  //   component: Layout,
  //   redirect: '/prescription/prescription-change/:id',
  //   name: 'Comments',
  //   meta: { title: '处方', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'prescription-change',
  //       name: 'PrescriptionChange',
  //       component: () => import('@/views/Prescription/Change.vue'),
  //       meta: { title: '修改处方', icon: 'Group 5 Copy 2' }
  //     }
  //   ]
  // },
 //  {
 //    path: '/customer',
 //    component: Layout,
 //    redirect: '/customer/customer-list',
 //    name: 'Customer',
 //    meta: { title: '客户管理', icon: 'customer' },
 //    children: [
 //      {
 //        path: 'customer-list',
 //        name: 'CustomerList',
 //        component: () => import('@/views/Customer/CustomerList.vue'),
 //        meta: { title: '客户列表', icon: '' }
 //      },
 //      {
 //        path: 'customer-detail/:id',
 //        name: 'CustomerDetail',
 //        component: () => import('@/views/Customer/CustomerDetail.vue'),
 //        meta: { title: '客户体检信息', icon: '',noCache: true, noVisit: true },
 //        hidden: true
 //      },
 //      {
 //        path: 'customer-intervene/:id',
 //        name: 'CustomerIntervene',
 //        component: () => import('@/views/Customer/CustomerIntervene.vue'),
 //        meta: { title: '客户干预情况', icon: '',noCache: true, noVisit: true },
 //        hidden: true
 //      },
 //      {
 //        path: 'company-list',
 //        name: 'CompanyList',
 //        component: () => import('@/views/Customer/CompanyList.vue'),
 //        meta: { title: '单位列表', icon: '' }
 //      },
 //      {
 //        path: 'company-detail/:id',
 //        name: 'CompanyDetail',
 //        component: () => import('@/views/Customer/CompanyDetail.vue'),
 //        meta: { title: '单位列表详情', icon: '',noCache: true, noVisit: true },
 //        hidden: true
 //      },
 //      {
 //        path: 'project-list',
 //        name: 'ProjectList',
 //        component: () => import('@/views/Customer/ProjectList.vue'),
 //        meta: { title: '项目列表', icon: '' }
 //      },
 //      {
 //        path: 'project-detail/:id',
 //        name: 'ProjectDetail',
 //        component: () => import('@/views/Customer/ProjectDetail.vue'),
 //        meta: { title: '项目列表详情', icon: '',noCache: true, noVisit: true },
 //        hidden: true
 //      },
 //    ]
 //  },
 //  {
 //    path: '/account',
 //    component: Layout,
 //    redirect: '/account/account-list',
 //    name: 'Customer',
 //    meta: { title: '账号管理', icon: 'user-settings-line' },
 //    children: [
 //      {
 //        path: 'account-list',
 //        name: 'AccountList',
 //        component: () => import('@/views/Account/AccountList.vue'),
 //        meta: { title: '员工列表', icon: '' }
 //      },
 //      {
 //        path: 'account-add',
 //        name: 'AccountAdd',
 //        component: () => import('@/views/Account/AccountAdd.vue'),
 //        meta: { title: '员工新增', icon: '' },
 //        hidden: true
 //      },
 //      {
 //        path: 'account-change/:id',
 //        name: 'AccountChange',
 //        component: () => import('@/views/Account/AccountChange.vue'),
 //        meta: { title: '员工修改', icon: '' },
 //        hidden: true
 //      },
 //      {
 //        path: 'role-list',
 //        name: 'RoleList',
 //        component: () => import('@/views/Account/RoleList.vue'),
 //        meta: { title: '角色列表', icon: '' }
 //      },
 //      {
 //        path: 'role-add',
 //        name: 'RoleAdd',
 //        component: () => import('@/views/Account/RoleAdd.vue'),
 //        meta: { title: '角色新增', icon: '' },
 //        hidden: true
 //      },
 //      {
 //        path: 'role-change/:id',
 //        name: 'RoleChange',
 //        component: () => import('@/views/Account/RoleChange.vue'),
 //        meta: { title: '角色修改', icon: '' },
 //        hidden: true
 //      },
 //    ]
 //  },

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/table',
  //   name: 'Example',
  //   meta: { title: 'Example', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'table',
  //       name: 'Table',
  //       component: () => import('@/views/table/index'),
  //       meta: { title: 'Table', icon: 'table' }
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/tree/index'),
  //       meta: { title: 'Tree', icon: 'tree' }
  //     }
  //   ]
  // },
  // {
  //   path: '/banner',
  //   component: Layout,
  //   name: 'Banner',
  //   redirect: '/banner/item',
  //   meta: { title: 'Banner相关', icon: 'wenzhang-copy' },
  //   children: [
  //     {
  //       path: 'item',
  //       name: 'BannerItem',
  //       component: () => import('@/views/Banner/Banner'),
  //       meta: { title: 'banner', icon: 'form' }
  //     },
  //     {
  //       path: 'type',
  //       name: 'BannerType',
  //       component: () => import('@/views/Banner/BannerType'),
  //       meta: { title: 'banner类别', icon: 'form' }
  //     }
  //   ]
  // },
  // {
  //   path: '/article',
  //   component: Layout,
  //   name: 'Article',
  //   redirect: '/article/article-list',
  //   meta: { title: '文章相关', icon: 'wenzhang-copy' },
  //   children: [
  //     {
  //       path: 'article-add',
  //       name: 'ArticleAdd',
  //       component: () => import('@/views/Article/ArticleAdd'),
  //       meta: { title: '文章新增', icon: 'form', noCache: true }
  //     },
  //     {
  //       path: 'article-edit/:article_id',
  //       name: 'ArticleEdit',
  //       component: () => import('@/views/Article/ArticleEdit'),
  //       meta: { title: '文章修改', icon: 'form', noCache: true, noVisit: true },
  //       hidden: true
  //     },
  //     {
  //       path: 'article-list',
  //       name: 'ArticleList',
  //       component: () => import('@/views/Article/ArticleList'),
  //       meta: { title: '文章列表', icon: 'table', noCache: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/user',
  //   component: Layout,
  //   name: 'User',
  //   redirect: '/user/user-list',
  //   meta: { title: '用户相关', icon: 'el-icon-user-solid' },
  //   children: [
  //     {
  //       path: 'user-edit',
  //       name: 'UserEdit',
  //       component: () => import('@/views/User/UserEdit'),
  //       meta: { title: '用户资料修改', icon: 'form' }

  //     },
  //     {
  //       path: 'user-list',
  //       name: 'UserList',
  //       component: () => import('@/views/User/UserList'),
  //       meta: { title: '用户列表', icon: 'table' }
  //     }
  //   ]
  // },

  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: 'Form', icon: 'form' }
  //     }
  //   ]
  // },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'Nested',
  //   meta: {
  //     title: 'Nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'Menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'Menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'Menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'Menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'Menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'Menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       name: 'Menu2',
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'http://kunic.cn',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
